package com.buanalintas.sandals.pos.entities;

import com.buanalintas.bynga.formatter.MoneyFormatter;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

@Entity
@Table(name = "pos_master_price_online")
@XmlRootElement
//@NamedQueries({
//    @NamedQuery(name = "PosMasterPriceOnline.findAll", query = "SELECT t FROM PosMasterPriceOnline t"),
//    @NamedQuery(name = "PosMasterPriceOnline.findBySync", query = "SELECT t FROM PosMasterPriceOnline t WHERE t.sync = :sync"),
//    @NamedQuery(name = "PosMasterPriceOnline.findByPriceOnlineId", query = "SELECT t FROM PosMasterPriceOnline t WHERE t.priceOnlineId = :priceOnlineId")
//})
public class PosMasterPriceOnline implements Serializable {
    @OneToMany(mappedBy = "itemPriceOnlineId")
    private Collection<PosMasterItem> posMasterItemCollection;

    private static final long serialVersionUID = 1L;
    @Column(name = "sync")
    private String sync;
    @Id
    @Basic(optional = false)
    @Column(name = "price_online_id")
    private Integer priceOnlineId;
    @Basic(optional = false)
    @Column(name = "price_online_value")
    private BigDecimal priceOnlineValue;

    public PosMasterPriceOnline() {
    }

    public Integer getPriceOnlineId() {
        return priceOnlineId;
    }

    public void setPriceOnlineId(Integer priceOnlineId) {
        this.priceOnlineId = priceOnlineId;
    }

    public BigDecimal getPriceOnlineValue() {
        return priceOnlineValue;
    }

    public void setPriceOnlineValue(BigDecimal priceOnlineValue) {
        this.priceOnlineValue = priceOnlineValue;
    }

    public String getSync() {
        return sync;
    }

    public void setSync(String sync) {
        this.sync = sync;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (priceOnlineId != null ? priceOnlineId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof PosMasterPriceOnline)) {
            return false;
        }
        PosMasterPriceOnline other = (PosMasterPriceOnline) object;
        if ((this.priceOnlineId == null && other.priceOnlineId != null) || (this.priceOnlineId != null && !this.priceOnlineId.equals(other.priceOnlineId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return MoneyFormatter.getInstance().format(priceOnlineValue);
    }

    @XmlTransient
    public Collection<PosMasterItem> getPosMasterItemCollection() {
        return posMasterItemCollection;
    }

    public void setPosMasterItemCollection(Collection<PosMasterItem> posMasterItemCollection) {
        this.posMasterItemCollection = posMasterItemCollection;
    }
}
